package codeTest.baidu;

import java.util.Scanner;

/**
 * AK
 * Author: shen qi han
 * Date: 2022/3/22 下午7:33
 */
public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int m = cin.nextInt();
        int[][] arr = new int[n][n];

        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                arr[i][j] = cin.nextInt();
            }
        }

        int[][] matrix = new int[n * m][n * m];
        for(int i = 0; i < n * m; i++){
            for(int j = 0; j < n * m; j++){
                matrix[i][j] = arr[i / m][j / m];
                System.out.print(matrix[i][j] + " ");
            }
            System.out.println();

        }

    }

}
